﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AssessmentLasResult.aspx.cs" Inherits="CRMWeb.Pages.Admin.AssessmentLasResult" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>OutSource Lender</title>
</head>
<body>
    <table id="dgAssessmentLastResult" title="Assessment LastResult" style="width: 600%; height: 380px; overflow-y: auto;"
        toolbar="#toolbarAssessmentLastResult" pagination="true" data-options="pageSize:10,pageList: [10,20,30,50]" rownumbers="true" fitcolumns="true" singleselect="true">
        <thead>
            <tr>
                <th field="AssessmentLId" width="100px" align="center">AssessmentLId</th>
                <th field="AssessmentLastResult" width="500px" align="center">Assessment LastResult</th>
            </tr>
        </thead>
    </table>
    <div id="toolbarAssessmentLastResult">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="newAssessmentLastResult()">New</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editAssessmentLastResult()">Edit</a>
        <a id="lnkDelete" href="javascript:void(0)" class="easyui-linkbutton" onclick="openDelASRPopup()" plain="true" iconcls="icon-remove" title="Delete Assessment LastResult">Delete</a>
    </div>
    <div id="dlgAssessmentLastResult" class="easyui-dialog" style="width: 350px; height: 220px; padding: 10px 20px"
        closed="true" buttons="#dlg-buttons">
        <div class="ftitle">Assessment LastResult Information</div>
        <form id="fmdlgAssessmentLastResult" method="post" novalidate>
            <div class="fitem">
                <label style="width: 140px;">Assessment LastResult:</label>
                <input id="txtAssessmentLastResult" style="width: 292px;" class="easyui-validatebox" required="true" />
                <input id="hdnAssessmentLId" value="" style="display: none" />
            </div>
        </form>
    </div>
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlgAssessmentLastResult').dialog('close')" style="float: left">Cancel</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveAssessmentLastResult()">Save</a>
    </div>

    <script type="text/javascript">

        var url;
        function newAssessmentLastResult() {
            $('#dlgAssessmentLastResult').dialog('open').dialog('setTitle', 'New Assessment LastResult');
            $('#fmdlgAssessmentLastResult').form('clear');
            $('#txtdlgAssessmentLastResult').val('');
            $('#hdnAssessmentLId').val('');
            url = '/WebServices/AssessmentLastResult/AssessmentLastResultAdd';
        }

        //Resize datagrid:
        window.onresize = function () {
            $('#dgAssessmentLastResult').datagrid('resize', {
                width: window.innerWidth - 165,
                height: window.innerHeight - 40
            });
        }

        function editAssessmentLastResult() {
            var row = $('#dgAssessmentLastResult').datagrid('getSelected');
            if (row) {
                $('#dlgAssessmentLastResult').dialog('open').dialog('setTitle', 'Edit Assessment LastResult');
                $('#fmdlgAssessmentLasResult').form('load', row);
                $('#txtAssessmentLastResult').val(row.AssessmentLastResult);
                $('#hdnAssessmentLId').val(row.AssessmentLId);
                url = '/WebServices/AssessmentLastResult/AssessmentLastResultEdit?AssessmentLId=' + row.AssessmentLId;
            }
        }

        function openDelASRPopup() {
            var row = $('#dgAssessmentLastResult').datagrid('getSelected');
            if (row) {
                $('#headertext').html("Are you sure want to delete this Assesment Result ?");
                $('#dlgDelconfirm').dialog('open');
                $('#btnDelete').bind("click", function () {
                    deleteAssessmentLastResult();
                });

            }
        }

        function deleteAssessmentLastResult() {
            var row = $('#dgAssessmentLastResult').datagrid('getSelected');
            if (row) {
                $.ajax({
                    url: '/WebServices/AssessmentLastResult.ashx',
                    type: 'POST',
                    data: {
                        method: 'AssessmentLastResultDelete',
                        args: { AssessmentLId: row.AssessmentLId }
                    },
                    success: function (data) {
                        $('#dgAssessmentLastResult').datagrid('reload');
                        $('#dlgDelconfirm').dialog('close');
                    }
                });
            }
        }
        function saveAssessmentLastResult() {
            var strAssessmentLastResult = $('#txtAssessmentLastResult').val();
            var AssessmentLId = $('#hdnAssessmentLId').val();

            if (AssessmentLId != '') {
                if (strAssessmentLastResult != '') {
                    $.ajax({
                        url: '/WebServices/AssessmentLastResult.ashx',
                        type: 'POST',
                        data: {
                            method: 'AssessmentLastResultEdit',
                            args: { AssessmentLId: AssessmentLId, AssessmentLastResult: strAssessmentLastResult }
                        },
                        success: function (data) {
                            if (data == 1) {
                                $('#dlgAssessmentLastResult').dialog('close');
                                $('#dgAssessmentLastResult').datagrid('reload');
                            }
                            else {
                                alert('Assessment LastResult already exist');
                            }
                        }
                    });
                }
            }
            else {
                if (strAssessmentLastResult != '') {
                    $.ajax({
                        url: '/WebServices/AssessmentLastResult.ashx',
                        type: 'POST',
                        data: {
                            method: 'AssessmentLastResultAdd',
                            args: { AssessmentLastResult: strAssessmentLastResult }
                        },
                        success: function (data) {
                            if (data == 1) {
                                $('#dlgAssessmentLastResult').dialog('close');
                                $('#dgAssessmentLastResult').datagrid('reload');
                            }
                            else {
                                alert('Assessment LastResult already exist.');
                            }
                        }
                    });
                }
            }
        }

        $(document).ready(function () {
            $('#dgAssessmentLastResult').datagrid({
                url: '/WebServices/AssessmentLastResult.ashx?method=AssessmentLastResultSelect',
                onDblClickRow: function (index, rowdata) {
                    editAssessmentLastResult();
                }
            });
        });

    </script>
</body>
</html>
